package com.otis.payroll;

import com.otis.DataFetch.Labcon;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class ReportGenerate {

    List data = new ArrayList();
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    Labcon lc = new Labcon();
    CallableStatement cs = null;

    public List fetchdata(String userid, String fromdate, String todate) {
        try {
            con = lc.getLocalConnection();
            cs = con.prepareCall("{call pr_payroll (?,?,?)}");
            cs.setString(1, userid);
            cs.setString(2, fromdate);
            cs.setString(3, todate);
          //  cs.addBatch();
           con.close();
            cs.close();

       //  cs.executeBatch();
         //System.out.println("Success "+ a);
            } catch (Exception e) {
                e.printStackTrace();
            }
        con = lc.getLocalConnection();
        try {
            String Qry = "select Payroll from webstars.dbo.tblPayrollReport";
            ps = con.prepareStatement(Qry);
           rs = ps.executeQuery();
           while (rs.next()) {
               String payroll = rs.getString(1);
               System.out.println(payroll);
               data.add(payroll);
           }
            //      int[] i2 =  ps.executeBatch();
              //    System.out.println(i2);
           //     int[] executeBatch = ps.executeBatch();
             //   System.out.println(executeBatch);
                  
                  con.close();
                  ps.close();
        } catch (SQLException ex) {
            System.out.println(ex);
        }
        return data;
    }
}
